package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.IDeleteVo;
import com.msh.frame.client.validation.IInsertVo;
import com.msh.frame.client.validation.IUpdateVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * @author shihu
 * @email m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(title = "ingressPo")
public class ModuleIngressPo extends BasePo {
  /**
  * 主键
  */
  @NotNull(groups = {IUpdateVo.class, IDeleteVo.class}, message = "id不能为空")
  @Schema(title = "主键")
  private Long id;

  /**
  * 项目id
  */
  @Schema(title = "项目id")
  private Long projectId;

  /**
  * 模块id
  */
  @NotNull(groups = {IInsertVo.class},message = "模块id不能为空")
  @Schema(title = "模块id")
  private Long moduleId;

  /**
  * 域名
  */
  @NotNull(groups = {IInsertVo.class},message = "域名不能为空")
  @Pattern(regexp = "^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$", message = "请输入正确的域名")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 100, message = "domain长度范围最大100")
  @Schema(title = "域名")
  private String domain;

  /**
  * 访问路径
  */
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 100, message = "requestPath长度范围最大100")
  @Schema(title = "访问路径")
  private String requestPath;

  /**
  * 应用路径
  */
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 100, message = "appPath长度范围最大100")
  @Schema(title = "应用路径")
  private String appPath;

  /**
  * 证书名
  */
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 20, message = "tslCert长度范围最大20")
  @Schema(title = "证书名")
  private String tslCert;

  /**
  * 租户
  */
  @Schema(title = "租户")
  private Long tenantId;

  /**
  * 更新版本
  */
  @NotNull(groups = {IUpdateVo.class}, message = "更新版本不能为空")
  @Schema(title = "更新版本")
  private Integer updateVersion;

  /**
  * 创建时间
  */
  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(title = "创建时间")
  private Date createTime;

  /**
  * 更新时间
  */
  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(title = "更新时间")
  private Date updateTime;



  public void initLoginAccount(ILoginAccount loginAccount){
    this.tenantId = loginAccount.getTenantId();
  }
}



